package com.info.zhiduoduo.repository.mapper.company;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.dto.company.RequestRefundListDto;
import com.info.zhiduoduo.repository.entity.company.EnterpriseRefund;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface EnterpriseRefundMapper extends BaseMapper<EnterpriseRefund> {

    @Select(" SELECT er.*,pay.pay_name,pay.pay_name_alias  " +
            " FROM zdd_enterprise_refund er " +
            " LEFT JOIN zdd_payment pay ON er.pay_id = pay.id" +
            " WHERE er.compid = #{compId} " +
            " AND IF(#{state} = 0,1 = 1,er.state = #{state}) " +
            " ORDER BY er.id DESC ")
    List<EnterpriseRefund> getCompanyRefund(@Param("compId") int compId,
                                            @Param("state") Integer state);

    @Select("SELECT er.* ,c.compname AS companyName,pay.pay_name,pay.pay_name_alias " +
            " FROM zdd_enterprise_refund er " +
            " LEFT JOIN zdd_company c ON c.compid = er.compid " +
            " LEFT JOIN zdd_payment pay ON er.pay_id = pay.id " +
            " WHERE c.compname LIKE CONCAT('%',#{companyName},'%') " +
            " AND IF(#{state} = 0,1 = 1,er.state = #{state}) " +
            " ORDER BY er.createtime DESC ")
    List<RequestRefundListDto> requestRefundList(@Param("companyName") String companyName,
                                                 @Param("state") Integer state);
}
